extends ../layout
block content
	.main-content
		.book#book
			-if(book.bookContent != null)
				h3.mb20
					-if(user != null)
						a#comment-btn.btn(href='javascript:;') 我要写书评
				.page-content
					.page(data-page=1) !{book.bookContent.contents[0].content}
						-if(user != null && user.name == book.publisher)
							a(href='/book/upbookContent/'+book._id+'/1') 修改本页
					-for(var i = 1; i < book.bookContent.contents.length; ++i)
						.page.none(data-page=i+1) !{book.bookContent.contents[i].content}
							-if(user != null && user.name == book.publisher)
								a(href='/book/upbookContent/'+book._id+'/'+(i+1)) 修改本页
				ul.page-control.mt20
					li.sel 1		
					-for(var i = 1; i < book.bookContent.contents.length; ++i)
						li=i+1
			-else if(user != null)
					p 这本书还没有内容
				-else
					p 这本书的贡献者还没有来得及上传内容哦～
			-if(error)
				p=error
		-if(user != null)
			.comment.none
				.close#close ×
				h3 我要为《#{book.name_zh}》写书评
				form#comment(method='get',action='/book/comment')
					input#bookId(type='hidden',value='#{book._id}',name='bookId')
					input#userId(type='hidden',value='#{user._id}',name='userId')
					label
						标题：
						input.title.selectize-input(type='text',name='title')
					label
						内容：
						textarea.content.selectize-input(name='commentContent')
					input#commit-btn.btn(type='button',value='提交')
		script.
			$(window).scroll(function(){
				if($(document).scrollTop()>80){
					$('#comment-btn').css({
						position :'fixed',
						top : '75px',
						right : '5px',
						zIndex : 2
					}).addClass('top-animate');
				}else{
					$('#comment-btn').css({position:'static'}).removeClass('top-animate');
				}
			});
			$(document).ready(function(){
				$('.page-control li').click(function(){
					var num = $(this).index();
					console.log(num);
					$(this).addClass('sel').siblings().removeClass('sel');
					$('.page:eq('+num+')').show().siblings().hide();
				});
			});
		script(type='text/javascript',src='/javascripts/page/commitContent.js')